#include "widget.h"
#include "ui_widget.h"

#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    //, ui(new Ui::Widget)
{
    //ui->setupUi(this);

//    QPushButton* button = new QPushButton(this);//创建按钮
//    button->setText("关闭");
//    button->move(200,300);

//    //    针对button    进行点击             widget  进行   关闭
//    connect(button, &QPushButton::clicked, this, &Widget::close);

    //关联自定义的信号和槽
    //connect(this, &Widget::mySignal, this, &Widget::handleMySignal);


    this->tch = new Teacher(this);
    this->stu = new Student(this);

    QPushButton *btn = new QPushButton("上课了", this);

    resize(800, 600);
    btn->move(100,100);


    connect(tch, &Teacher::MySignal, stu, &Student::StartStuday);

    connect(btn, &QPushButton::clicked, tch, &Teacher::MySignal);

    EmitSignal();
}

Widget::~Widget()
{
    //delete ui;

}

void Widget::EmitSignal()
{
    emit tch->MySignal();
}


//void Widget::handleMySignal()
//{
//    this->setWindowTitle("处理自定义信号");
//}

//void Widget::on_pushButton_clicked()
//{
//    emit mySignal();
//}

//自动生成的槽函数原型框架
//void Widget::on_pushButton_clicked()
//{
//    this->close();//添加关闭窗口的代码
//}
